package com.hotel.controller;

import com.hotel.pojo.Dept;
import com.hotel.pojo.User;
import com.hotel.service.DeptService;
import com.hotel.vo.PageResult;
import com.hotel.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@CrossOrigin
@RequestMapping("/dept")
public class DeptController {
    @Autowired
    private DeptService deptService;

    /**
     * 分页查询
     * @param pageResult
     * @return
     */
    @GetMapping("/list")
    public SysResult getDeptList(PageResult pageResult){
        pageResult =deptService.getDeptList(pageResult);
        return SysResult.success(pageResult);
    }

    /**
     * 根据Id查
     * @param deptId
     * @return
     */
    @GetMapping("/{deptId}")
    public SysResult findDeptById(@PathVariable Integer deptId){
        Dept dept=deptService.findDeptById(deptId);
        return SysResult.success(dept);
    }


}
